/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */

package com.globussoft.util;

/**
 *
 * @author Globussoft
 */
public class FormatedTime {

public static long getFormatedTimeLong(String filesize) {//1 GB 2 MB 4 KB 820 bytes
        long size = 0;
        if (filesize.contains("Hrs")) {
            size = (long) Integer.parseInt(filesize.substring(0, filesize.indexOf("Hrs")).trim()) * 1000*60*60*60;
            filesize = filesize.substring(filesize.indexOf("Hrs") + "Hrs".length()).trim();
        }
        if (filesize.contains("Min")) {
            size = size + (long) Integer.parseInt(filesize.substring(0, filesize.indexOf("Min")).trim()) *1000*60*60;
            filesize = filesize.substring(filesize.indexOf("Min") + "Min".length()).trim();
        }
        if (filesize.contains("Sec")) {
            size = size + (long) Integer.parseInt(filesize.substring(0, filesize.indexOf("Sec")).trim()) * 1000*60;
            filesize = filesize.substring(filesize.indexOf("Sec") + "Sec".length()).trim();
        }
        if (filesize.contains("Mic")) {
            size = size + (long) Integer.parseInt(filesize.substring(0, filesize.indexOf("Mic")).trim());
            filesize = filesize.substring(filesize.indexOf("Mic") + "Mic".length()).trim();
        }

        return size;
    }
  public
  static String getFormatedTimeString(long totalTime) {
        String time = "";
        if (totalTime >= 7 * 24 * 1000 * 60 * 60) {
            time = String.valueOf(totalTime / (7 * 24 * 1000 * 60 * 60)) + " " + "Week ";
            totalTime = totalTime % (7 * 24 * 1000 * 60 * 60);
        }
        if (totalTime >= 24 * 1000 * 60 * 60) {
            time = String.valueOf(totalTime / (24 * 1000 * 60 * 60)) + " " + "Day ";
            totalTime = totalTime % (24 * 1000 * 60 * 60);
        }
        if (totalTime >= 1000 * 60 * 60) {
            time = String.valueOf(totalTime / (1000 * 60 * 60)) + " " + "Hrs ";
            totalTime = totalTime % (1000 * 60 * 60);
        }
        if (totalTime >= 1000 * 60) {
            time = time + String.valueOf(totalTime / (1000 * 60)) + " " + "Min ";
            totalTime = totalTime % (1000 * 60);
        }
        if (totalTime >= 1000) {
            time = time + String.valueOf(totalTime / (1000)) + " " + "Sec ";
            totalTime = totalTime % (1000);
        }
        if (totalTime > 0) {
            time = time + String.valueOf(totalTime) + " " + "Mic ";
        }
        return time;
    }

}
